home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 1.7 KB | 94 lines | [TEXT/CWIE] |
- // GrafPortObject.cp
-
- #ifndef GrafPortObject_h
- #include "GrafPortObject.h"
- #endif
- #ifndef QuickDrawError_h
- #include "QuickDrawError.h"
- #endif
-
- GrafPortObject::GrafPortObject()
- {
- OpenCPort( &UncheckedColorCast() );
- QuickDrawError::Check().Throw();
- }
-
- GrafPortObject::~GrafPortObject()
- {
- CloseCPort( &ColorCast() );
- QuickDrawError::Check().Throw();
- }
-
- Rectangle GrafPortObject::LocalBitMapBounds() const
- {
- return InColor()
- ? (*UncheckedColorCast().portPixMap)->bounds
- : portBits.bounds;
- }
-
- PointObject GrafPortObject::GlobalToLocal() const
- {
- return LocalBitMapBounds().TopLeft();
- }
-
- PointObject GrafPortObject::LocalToGlobal() const
- {
- return -GlobalToLocal();
- }
-
- Rectangle GrafPortObject::GlobalBounds() const
- {
- Rectangle bounds( LocalBounds() );
- bounds += LocalToGlobal();
- return bounds;
- }
-
- RGBColor GrafPortObject::ForegroundColor() const
- {
- Assert( IsCurrent() );
- Assert( InColor() );
- RGBColor result;
- GetForeColor( &result );
- return result;
- }
-
- RGBColor GrafPortObject::BackgroundColor() const
- {
- Assert( IsCurrent() );
- Assert( InColor() );
- RGBColor result;
- GetBackColor( &result );
- return result;
- }
-
- ::Face GrafPortObject::Face() const
- {
- return ::Face( Font(), TextSize(), Style() );
- }
-
- void GrafPortObject::SetFace( const ::Face& face )
- {
- Assert( IsCurrent() );
-
- if ( Font() != face.Font() )
- SetFont( face.Font() );
-
- if ( TextSize() != face.Size() )
- SetTextSize( face.Size() );
-
- if ( Style() != face.Style() )
- SetStyle( face.Style() );
- }
-
- void GrafPortObject::SetCharacterStretch( Fixed stretch )
- {
- Assert( IsCurrent() );
- Assert( InColor() );
- CharExtra( stretch );
- }
-
- Fixed GrafPortObject::CharacterStretch() const
- {
- return ColorCast().chExtra;
- }
-